public class RegularPolygon {
private int n = 3;
private double side = 1.0;
private double x = 0.0;
private double y = 0.0;

// 无参构造函数
public RegularPolygon() {
}

// 指定边数和边长的构造函数
public RegularPolygon(int n, double side) {
    this.n = n;
    this.side = side;
}

// 指定所有属性的构造函数
public RegularPolygon(int n, double side, double x, double y) {
    this.n = n;
    this.side = side;
    this.x = x;
    this.y = y;
}

// 访问器和修改器方法
public int getN() {
    return n;
}

public void setN(int n) {
    this.n = n;
}

public double getSide() {
    return side;
}

public void setSide(double side) {
    this.side = side;
}

public double getX() {
    return x;
}

public void setX(double x) {
    this.x = x;
}

public double getY() {
    return y;
}

public void setY(double y) {
    this.y = y;
}

// 计算周长
public double getPerimeter() {
    return n * side;
}

// 计算面积
public double getArea() {
    return (n * side * side) / (4 * Math.tan(Math.PI / n));
}

// toString 方法
@Override
public String toString() {
    return String.format("RegularPolygon[n=%d, side=%.2f, center=(%.2f,%.2f), perimeter=%.2f, area=%.2f]", 
                       n, side, x, y, getPerimeter(), getArea());
}
}
public class TestRegularPolygon {
public static void main(String[] args) {
// 创建三个正多边形对象
RegularPolygon polygon1 = new RegularPolygon();
RegularPolygon polygon2 = new RegularPolygon(6, 4);
RegularPolygon polygon3 = new RegularPolygon(10, 4, 5.6, 7.8);

    // 使用toString方法显示对象
    System.out.println("Polygon 1: " + polygon1.toString());
    System.out.println("Polygon 2: " + polygon2.toString());
    System.out.println("Polygon 3: " + polygon3.toString());
}
}